package tpi.obj3.planificador.serializer;

import com.google.inject.Inject;
import com.google.inject.Provider;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.xtext.serializer.acceptor.ISemanticSequenceAcceptor;
import org.eclipse.xtext.serializer.acceptor.SequenceFeeder;
import org.eclipse.xtext.serializer.diagnostic.ISemanticSequencerDiagnosticProvider;
import org.eclipse.xtext.serializer.diagnostic.ISerializationDiagnostic.Acceptor;
import org.eclipse.xtext.serializer.sequencer.AbstractDelegatingSemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.GenericSequencer;
import org.eclipse.xtext.serializer.sequencer.ISemanticNodeProvider.INodesForEObjectProvider;
import org.eclipse.xtext.serializer.sequencer.ISemanticSequencer;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService;
import org.eclipse.xtext.serializer.sequencer.ITransientValueService.ValueTransient;
import tpi.obj3.planificador.planificador.Asignacion;
import tpi.obj3.planificador.planificador.Aula;
import tpi.obj3.planificador.planificador.Clase;
import tpi.obj3.planificador.planificador.Docente;
import tpi.obj3.planificador.planificador.Materia;
import tpi.obj3.planificador.planificador.Modelo;
import tpi.obj3.planificador.planificador.Planificacion;
import tpi.obj3.planificador.planificador.PlanificadorPackage;
import tpi.obj3.planificador.planificador.Recurso;
import tpi.obj3.planificador.services.PlanificadorGrammarAccess;

@SuppressWarnings("all")
public class PlanificadorSemanticSequencer extends AbstractDelegatingSemanticSequencer {

	@Inject
	private PlanificadorGrammarAccess grammarAccess;
	
	public void createSequence(EObject context, EObject semanticObject) {
		if(semanticObject.eClass().getEPackage() == PlanificadorPackage.eINSTANCE) switch(semanticObject.eClass().getClassifierID()) {
			case PlanificadorPackage.ASIGNACION:
				if(context == grammarAccess.getAsignacionRule() ||
				   context == grammarAccess.getElementoRule()) {
					sequence_Asignacion(context, (Asignacion) semanticObject); 
					return; 
				}
				else break;
			case PlanificadorPackage.AULA:
				if(context == grammarAccess.getAulaRule() ||
				   context == grammarAccess.getElementoRule()) {
					sequence_Aula(context, (Aula) semanticObject); 
					return; 
				}
				else break;
			case PlanificadorPackage.CLASE:
				if(context == grammarAccess.getClaseRule() ||
				   context == grammarAccess.getElementoRule()) {
					sequence_Clase(context, (Clase) semanticObject); 
					return; 
				}
				else break;
			case PlanificadorPackage.DOCENTE:
				if(context == grammarAccess.getDocenteRule() ||
				   context == grammarAccess.getElementoRule()) {
					sequence_Docente(context, (Docente) semanticObject); 
					return; 
				}
				else break;
			case PlanificadorPackage.MATERIA:
				if(context == grammarAccess.getElementoRule() ||
				   context == grammarAccess.getMateriaRule()) {
					sequence_Materia(context, (Materia) semanticObject); 
					return; 
				}
				else break;
			case PlanificadorPackage.MODELO:
				if(context == grammarAccess.getModeloRule()) {
					sequence_Modelo(context, (Modelo) semanticObject); 
					return; 
				}
				else break;
			case PlanificadorPackage.PLANIFICACION:
				if(context == grammarAccess.getElementoRule() ||
				   context == grammarAccess.getPlanificacionRule()) {
					sequence_Planificacion(context, (Planificacion) semanticObject); 
					return; 
				}
				else break;
			case PlanificadorPackage.RECURSO:
				if(context == grammarAccess.getElementoRule() ||
				   context == grammarAccess.getRecursoRule()) {
					sequence_Recurso(context, (Recurso) semanticObject); 
					return; 
				}
				else break;
			}
		if (errorAcceptor != null) errorAcceptor.accept(diagnosticProvider.createInvalidContextOrTypeDiagnostic(semanticObject, context));
	}
	
	/**
	 * Constraint:
	 *     (docente=[Docente|ID] materia=[Materia|ID])
	 */
	protected void sequence_Asignacion(EObject context, Asignacion semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, PlanificadorPackage.Literals.ASIGNACION__DOCENTE) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificadorPackage.Literals.ASIGNACION__DOCENTE));
			if(transientValues.isValueTransient(semanticObject, PlanificadorPackage.Literals.ASIGNACION__MATERIA) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificadorPackage.Literals.ASIGNACION__MATERIA));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getAsignacionAccess().getDocenteDocenteIDTerminalRuleCall_0_0_1(), semanticObject.getDocente());
		feeder.accept(grammarAccess.getAsignacionAccess().getMateriaMateriaIDTerminalRuleCall_2_0_1(), semanticObject.getMateria());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     name=ID
	 */
	protected void sequence_Aula(EObject context, Aula semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, PlanificadorPackage.Literals.AULA__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificadorPackage.Literals.AULA__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getAulaAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (inicio=INT fin=INT materia=[Materia|ID] aula=[Aula|ID])
	 */
	protected void sequence_Clase(EObject context, Clase semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, PlanificadorPackage.Literals.CLASE__INICIO) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificadorPackage.Literals.CLASE__INICIO));
			if(transientValues.isValueTransient(semanticObject, PlanificadorPackage.Literals.CLASE__FIN) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificadorPackage.Literals.CLASE__FIN));
			if(transientValues.isValueTransient(semanticObject, PlanificadorPackage.Literals.CLASE__MATERIA) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificadorPackage.Literals.CLASE__MATERIA));
			if(transientValues.isValueTransient(semanticObject, PlanificadorPackage.Literals.CLASE__AULA) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificadorPackage.Literals.CLASE__AULA));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getClaseAccess().getInicioINTTerminalRuleCall_1_0(), semanticObject.getInicio());
		feeder.accept(grammarAccess.getClaseAccess().getFinINTTerminalRuleCall_3_0(), semanticObject.getFin());
		feeder.accept(grammarAccess.getClaseAccess().getMateriaMateriaIDTerminalRuleCall_4_0_1(), semanticObject.getMateria());
		feeder.accept(grammarAccess.getClaseAccess().getAulaAulaIDTerminalRuleCall_6_0_1(), semanticObject.getAula());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (dedicacion=Dedicacion name=ID)
	 */
	protected void sequence_Docente(EObject context, Docente semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, PlanificadorPackage.Literals.DOCENTE__DEDICACION) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificadorPackage.Literals.DOCENTE__DEDICACION));
			if(transientValues.isValueTransient(semanticObject, PlanificadorPackage.Literals.DOCENTE__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificadorPackage.Literals.DOCENTE__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getDocenteAccess().getDedicacionDedicacionParserRuleCall_1_0(), semanticObject.getDedicacion());
		feeder.accept(grammarAccess.getDocenteAccess().getNameIDTerminalRuleCall_2_0(), semanticObject.getName());
		feeder.finish();
	}
	
	
	/**
	 * Constraint:
	 *     (name=ID horas=INT dias=INT requerimientos+=[Recurso|ID]*)
	 */
	protected void sequence_Materia(EObject context, Materia semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     elementos+=Elemento*
	 */
	protected void sequence_Modelo(EObject context, Modelo semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     (
	 *         anio=INT 
	 *         semestre=INT 
	 *         materias+=[Materia|ID]* 
	 *         clasesLunes+=Clase* 
	 *         clasesMartes+=Clase* 
	 *         clasesMiercoles+=Clase* 
	 *         clasesJueves+=Clase* 
	 *         clasesViernes+=Clase* 
	 *         clasesSabado+=Clase*
	 *     )
	 */
	protected void sequence_Planificacion(EObject context, Planificacion semanticObject) {
		genericSequencer.createSequence(context, semanticObject);
	}
	
	
	/**
	 * Constraint:
	 *     name=ID
	 */
	protected void sequence_Recurso(EObject context, Recurso semanticObject) {
		if(errorAcceptor != null) {
			if(transientValues.isValueTransient(semanticObject, PlanificadorPackage.Literals.RECURSO__NAME) == ValueTransient.YES)
				errorAcceptor.accept(diagnosticProvider.createFeatureValueMissing(semanticObject, PlanificadorPackage.Literals.RECURSO__NAME));
		}
		INodesForEObjectProvider nodes = createNodeProvider(semanticObject);
		SequenceFeeder feeder = createSequencerFeeder(semanticObject, nodes);
		feeder.accept(grammarAccess.getRecursoAccess().getNameIDTerminalRuleCall_1_0(), semanticObject.getName());
		feeder.finish();
	}
}
